<template>
  <div style="background-color: #f7f8fa; min-height: 100vh">
    <div class="newFirst">
      <div class="quarter_item">
        <div class="top_box">
          <span style="font-size: 36px">1</span><span>th</span>
        </div>
        <p class="title">第一季度</p>
        <p class="line_title">The first quarter</p>
        <div class="line"></div>
        <p class="money">4,000</p>
        <p class="last"><span>+0%</span><span>与去年同期数据持平</span></p>
      </div>
      <div class="quarter_item">
        <div class="top_box" style="background-color: #ff6cb3">
          <span style="font-size: 36px">2</span><span>th</span>
        </div>
        <p class="title">第二季度</p>
        <p class="line_title">Second quarter</p>
        <div class="line"></div>
        <p class="money">4,000</p>
        <p class="last">
          <span style="color: #e53e3e">+5%</span><span>与去年同期上升5%</span>
        </p>
      </div>
      <div class="quarter_item">
        <div class="top_box" style="background-color: #ffa564">
          <span style="font-size: 36px">3</span><span>th</span>
        </div>
        <p class="title">第二季度</p>
        <p class="line_title">The third quarter</p>
        <div class="line"></div>
        <p class="money">4,000</p>
        <p class="last">
          <span style="color: #48bb78">-15%</span><span>与去年同期下降15%</span>
        </p>
      </div>
      <div class="quarter_item">
        <div class="top_box" style="background-color: #646cff">
          <span style="font-size: 36px">4</span><span>th</span>
        </div>
        <p class="title">第二季度</p>
        <p class="line_title">Fourth quarter</p>
        <div class="line"></div>
        <p class="money">4,000</p>
        <p class="last">
          <span style="color: #e53e3e">+5%</span><span>与去年同期上升5%</span>
        </p>
      </div>
    </div>
    <div class="FirstLine">
      <div class="box" id="main"></div>
      <div class="box" id="mainPie"></div>
      <div class="box" id="mainLine"></div>
    </div>
  </div>
</template>

<script>
const echarts = require("echarts/lib/echarts");
require("echarts/lib/component/tooltip");
require("echarts/lib/component/legend");
require("echarts/lib/component/grid");
require("echarts/lib/chart/line");
require("echarts/lib/chart/bar");
require("echarts/lib/chart/pie");
export default {
  data() {
    return {};
  },
  mounted() {
    this.getBar();
    this.getPie();
    this.getLine();
  },
  methods: {
    getBar() {
      var chartDom = document.getElementById("main");
      var myChart = echarts.init(chartDom);
      var option;
      option = {
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "shadow",
          },
        },
        grid: {
          left: "3%",
          right: "4%",
          bottom: "3%",
          containLabel: true,
        },
        xAxis: {
          type: "category",
          data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
        },
        yAxis: {
          type: "value",
        },
        series: [
          {
            data: [120, 200, 150, 80, 70, 110, 130],
            type: "bar",
          },
        ],
      };
      option && myChart.setOption(option);
    },
    getPie() {
      var chartDom = document.getElementById("mainPie");
      var myChart = echarts.init(chartDom);
      var option;

      option = {
        tooltip: {
          trigger: "item",
        },
        legend: {
          top: "5%",
          left: "center",
        },
        series: [
          {
            name: "Access From",
            type: "pie",
            radius: ["40%", "70%"],
            avoidLabelOverlap: false,
            itemStyle: {
              borderRadius: 10,
              borderColor: "#fff",
              borderWidth: 2,
            },
            label: {
              show: false,
              position: "center",
            },
            emphasis: {
              label: {
                show: true,
                fontSize: 40,
                fontWeight: "bold",
              },
            },
            labelLine: {
              show: false,
            },
            data: [
              { value: 1048, name: "Search Engine" },
              { value: 735, name: "Direct" },
              { value: 580, name: "Email" },
              { value: 484, name: "Union Ads" },
              { value: 300, name: "Video Ads" },
            ],
          },
        ],
      };

      option && myChart.setOption(option);
    },
    getLine() {
      var chartDom = document.getElementById("mainLine");
      var myChart = echarts.init(chartDom);
      var option;

      option = {
        tooltip: {
          trigger: "axis",
        },
        legend: {
          data: ["Email", "Union Ads", "Video Ads", "Direct", "Search Engine"],
        },
        grid: {
          left: "3%",
          right: "4%",
          bottom: "3%",
          containLabel: true,
        },
        xAxis: {
          type: "category",
          boundaryGap: false,
          data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
        },
        yAxis: {
          type: "value",
        },
        series: [
          {
            name: "Email",
            type: "line",
            stack: "Total",
            data: [120, 132, 101, 134, 90, 230, 210],
          },
          {
            name: "Union Ads",
            type: "line",
            stack: "Total",
            data: [220, 182, 191, 234, 290, 330, 310],
          },
          {
            name: "Video Ads",
            type: "line",
            stack: "Total",
            data: [150, 232, 201, 154, 190, 330, 410],
          },
          {
            name: "Direct",
            type: "line",
            stack: "Total",
            data: [320, 332, 301, 334, 390, 330, 320],
          },
          {
            name: "Search Engine",
            type: "line",
            stack: "Total",
            data: [820, 932, 901, 934, 1290, 1330, 1320],
          },
        ],
      };

      option && myChart.setOption(option);
    },
  },
};
</script>

<style scoped lang="scss">
.newFirst {
  padding-top: 30px;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: space-around;

  .quarter_item {
    min-width: 240px;
    width: 15%;
    height: 240px;
    background: #ffffff;
    box-shadow: 0px 3px 6px 0px rgba(0, 0, 0, 0.02);
    border-radius: 16px;
    margin-left: 20px;
    margin-bottom: 17px;

    .top_box {
      margin: 16px auto 0;
      width: 64px;
      height: 64px;
      background: #6488ff;
      box-shadow: 0px 3px 6px 0px rgba(0, 0, 0, 0.02);
      border-radius: 12px;
      text-align: center;

      span {
        font-size: 18px;
        font-family: Poppins, Poppins;
        font-weight: 700;
        color: #ffffff;
        line-height: 64px;
      }
    }

    .title {
      text-align: center;
      font-size: 18px;
      font-family: Source Han Sans, Source Han Sans;
      font-weight: 700;
      color: #2d3748;
      margin: 0;
      margin-top: 16px;
    }

    .line_title {
      text-align: center;
      font-size: 12px;
      font-family: Source Han Sans, Source Han Sans;
      font-weight: 700;
      color: #a0aec0;
      margin: 0;
      margin-top: 4px;
    }

    .line {
      margin: 12px auto 0;
      width: 172px;
      height: 0px;
      opacity: 1;
      border: 1px solid;
      border-image: linear-gradient(
          270deg,
          rgba(224.000001847744, 225.00000178813934, 226.0000017285347, 0),
          rgba(224.000001847744, 225.00000178813934, 226.0000017285347, 1),
          rgba(224.000001847744, 225.00000178813934, 226.0000017285347, 0.15625)
        )
        1 1;
    }

    .money {
      margin: 0;
      text-align: center;
      margin-top: 14px;
      font-size: 20px;
      font-family: Poppins, Poppins;
      font-weight: 700;
      color: #2d3748;
    }

    .last {
      margin: 0;
      margin-top: 12px;
      display: flex;
      align-items: center;
      justify-content: center;

      span:nth-child(1) {
        font-size: 14px;
        font-family: Poppins, Poppins;
        font-weight: 700;
        color: #7e7e89;
      }

      span:nth-child(2) {
        font-size: 12px;
        font-family: Poppins, Poppins;
        font-weight: 700;
        color: #a0aec0;
      }
    }
  }
}

.FirstLine {
  width: 100%;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-around;

  .box {
    width: 400px;
    height: 340px;
    background: #ffffff;
    box-shadow: 0px 3px 6px 0px rgba(0, 0, 0, 0.02);
    border-radius: 16px;
    margin-bottom: 30px;
  }
}
</style>
